<?php
	include("../include/config.php");
	include("../include/functions.php");
	$_POST['created_date'] = date("Y-m-d H:i:s");
	$_POST['updated_date'] = date("Y-m-d H:i:s");
	if($_GET['table']){
		deleterow($_GET['table'],array('id'=>$_GET['id']));
		header("location:../index.php?data=broucher&msg=delete");
	}else{
		foreach($_FILES as $userfile)
		{
			 // store the file information to variables for easier access
			for($i=0;$i<count($userfile['name']);$i++)
			{
				$tmp_name = $userfile['tmp_name'][$i];
				$type = $userfile['type'];
				$name = $userfile['name'][$i];
				$size = $userfile['size'];
$img=rand().$name;
				$imagespath="../../brochure/".$img;
				copy($tmp_name,$imagespath);
				$_POST['brochure']=$img;				//print_r($_POST); exit;
			   db_insert('brochure',$_POST);
			}
		}
		
				
		
		header("location:../index.php?data=broucher&msg=success");
	}
?>